<template>
  <div style="background-color: white ;height: 100%">
    <el-tag size="medium" style="height: 42px;margin-left: 10px;margin-top: 15px;">待审批信息</el-tag>
    <div>
        <el-table :data="tableData" stripe style="width: 100%" :header-cell-style="{textAlign: 'center'}"
                  :cell-style="{ textAlign: 'center' }">
          <el-table-column label="编号" prop="id" width="55" v-if="show" type="index"/>
          <el-table-column label="车牌号" prop="licensePlate"/>
          <el-table-column label="车辆名称" prop="brand"/>
          <el-table-column label="申请人" prop="empName"/>
          <el-table-column label="申请时间" prop="applicDate"/>
          <el-table-column label="开始时间" prop="kaishiTime"/>
          <el-table-column label="结束时间" prop="jieshuTime"/>
          <el-table-column label="当前状态" prop="approved">
            <template #default="e">
              <template v-if="e.row.approved===false">
                <el-tag type="danger">待审批</el-tag>
              </template>
            </template>
          </el-table-column>

          <el-table-column label="操作" width="180">
            <template #default="scope">
              <el-button size="mini"
                         type="primary"
                         plain
                         @click="handleEdit(scope.$index, scope.row)">同意</el-button>
              <el-button
                  size="mini"
                  type="danger"
                  plain
                  @click="handleDelete(scope.$index, scope.row)">不同意</el-button>
            </template>
          </el-table-column>
        </el-table>
    </div>

  </div>
</template>

<script>
import {daishengpi, wancheng} from "../../../../network/process/vehicle-process";

export default {
  data() {
    return {
      show:true,
      tableData: [],
      searche:{
        empId:null,
      }
    }
  },
  methods:{
//待审批信息
    daishengpi(){
      let params={
        empId: 9
      }
      daishengpi(params).then(data=>{
        this.tableData= data.data;
        console.log("待审批信息：",data)
      })
    },

    handleEdit(index, row) {
      console.log(index, row)
      console.log(row.taskId)
      let params={
        approved:true,
        processInstanceId:row.processInstanceId,
        taskId:row.taskId,
        licensePlate:row.licensePlate
      }
      wancheng(params).then(e=>{
        this.daishengpi();
      })



    },
    handleDelete(index, row) {
      console.log(index, row)
      let params={
        approved:false,
        processInstanceId:row.processInstanceId,
        taskId:row.taskId,
        licensePlate:row.licensePlate
      }
      wancheng(params).then(e=>{
        this.daishengpi();
      })
    },
  },
  created() {
    this.daishengpi();
  }
}
</script>

<style scoped>

</style>